//
//  MAFuncCollectionCell.m
//  meiang_edu
//
//  Created by Liubi_Chaos_G on 2018/8/3.
//  Copyright © 2018年 com.meiang.meiang_edu. All rights reserved.
//

#import "MAFuncCollectionCell.h"
#import "MAJiGouModel.h"

#import "MAHomeWorkEditFinishVC.h"

@interface MAFuncCollectionCell ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *centerYCons;
@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *detailLabel;
@property (weak, nonatomic) IBOutlet UIButton *followBtn;
@property (weak, nonatomic) IBOutlet UIButton *msgBtn;
@property (weak, nonatomic) IBOutlet UIImageView *bgImgView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *iconViewWidthCons;

@end

@implementation MAFuncCollectionCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.followBtn.layer.cornerRadius = 3;
    self.followBtn.layer.masksToBounds = YES;
    self.followBtn.hidden = YES;
    
    self.msgBtn.layer.cornerRadius = 3;
    self.msgBtn.layer.masksToBounds = YES;
    if (IS_IPHONE_5) {
        self.iconViewWidthCons.constant = 50;
        self.iconView.layer.cornerRadius = 25;
        self.iconView.layer.masksToBounds = YES;
    } else {
        self.iconViewWidthCons.constant = 72;
        self.iconView.layer.cornerRadius = 36;
        self.iconView.layer.masksToBounds = YES;
    }
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil] lastObject];
    }
    return self;
}
- (IBAction)focusBtnDidClick {
    DLog(@"+关注");
}
- (IBAction)msgBtnDidClick
{
    MAHomeWorkEditFinishVC *vc = [[MAHomeWorkEditFinishVC alloc]init];
    vc.giscene = @"organization_notice_leave";
    vc.or_id = self.model.ID;
    //        vc.keyid = self.keyid;
    [self.viewController.navigationController pushViewController:vc animated:YES];
}

#pragma mark - getter & setter
- (void)setModel:(MAJiGouModel *)model {
    _model = model;
    if ([_model.ortype isEqualToString:@"family"])
    {
        self.msgBtn.hidden = YES;
    }
    else
    {
        self.msgBtn.hidden = NO;
    }
    [self.bgImgView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IMG_OSS,model.cbackground]] placeholderImage:[UIImage imageNamed:@""]];
    [self.iconView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IMG_OSS,model.ps_id]] placeholderImage:[UIImage imageNamed:@"homepage_navigationbar_picture"]];
    self.nameLabel.text = model.ccaption;
    self.detailLabel.text = model.ortype;
}
@end
